/**
 * Created by zhangjinrui on 17/6/27.
 */

public class Solution593 {

    public static void main(String args[]) {
        Solution593 s = new Solution593();
        int[] a = new int[]{0, 0};
        int[] b = new int[]{0, 1};
        int[] c = new int[]{1, 1};
        int[] d = new int[]{1, 0};
        System.out.println(s.validSquare(a, b, c, d));
    }

    public boolean validSquare(int[] p1, int[] p2, int[] p3, int[] p4) {
        if (!equal(p1, p2, p3) || !equal(p1, p2, p4) || !equal(p2, p3, p4)) {
            return false;
        }

        if (!calAngle(p1, p2, p3) && !calAngle(p1, p3, p4) && !calAngle(p2, p3, p4)) {
            return false;
        }
        return true;
    }

    public boolean equal(int[] p1, int[] p2, int p3[]) {
        long a = calEdge(p1, p2);
        long b = calEdge(p2, p3);
        return a == b;
    }

    public boolean calAngle(int[] p1, int[] p2, int[] p3) {
        int[] a = new int[]{p2[0] - p1[0], p2[1] - p1[1]};
        int[] b = new int[]{p3[0] - p1[0], p3[1] - p1[1]};
        int[] c = new int[]{p3[0] - p2[0], p3[1] - p2[1]};

        if (a[0] * b[0] + a[1] * b[1] == 0 || c[0] * b[0] + c[1] * b[1] == 0) {
            return true;
        }
        return false;
    }

    public long calEdge(int[] p1, int[] p2) {
        long res = 1L;
        return res + (p2[0] - p1[0]) * (p2[0] - p1[0]) + (p2[1] - p1[1]) * (p2[1] - p1[1]);
    }
}
